<?php
class login_model extends Model
{
	function login_model()
	{
		parent::Model();
	}
	
	function checklogin()
	{
		$username = $this->input->post('user_login');
		$password = md5($this->input->post('user_pass'));
		$this->db->where('LoginName',$username);
		$this->db->where('Passwd',$password);
		$query = $this->db->get('admin');
		if($query->row())
		{
			$row = $query->row_array();
			$this->session->sess_destroy();
			$this->session->sess_create(); 
			//Set session data 
			$this->session->set_userdata($row);
			
			//Set logged_in to true
			$this->session->set_userdata(array('logged_in' => true));               
			return true;
		}
		else
		{
			return false;
		}          
	}
	
}
?>
